package com.java.st.lib.tools.secutiry;

public final class KeyFactory {

	private final static String KEY_FOR_SYSTEM = "!$%^@abcd#$#@system";
	private final static String KEY_FOR_VALIDATIONCODE = "!$%^@abcd#$#@validationcode";

	public static String createKeyForSystem(Long userId, Integer type) {
		int key = (userId + "-" + type + "-" + KEY_FOR_SYSTEM).hashCode();
		return MD5Utils.md5With32(key + "");
	}
	
	public static String createKeyForSystem(Long userId, Integer type, String randomStr) {
		int key = (userId + "-" + type + "-" + randomStr + "-" + KEY_FOR_SYSTEM).hashCode();
		return MD5Utils.md5With32(key + "");
	}

	public static String createValidationCode(String code) {
		int key = (code + KEY_FOR_VALIDATIONCODE).hashCode();
		return MD5Utils.md5With32(key + "");
	}

}
